﻿using System;
using System.Collections.Generic;
//using System.Linq;
//using System.Text;
using System.IO;
using Allegro.Framework;
//using Cosmologica.Framework;

namespace Allegro.Mathlib
{
    public interface IResultset
    {   
        /// <summary>
        /// Add Data point
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        void AddData(double x, double[] y);

        /// <summary>
        /// Length of the resultset (number of data points added)
        /// </summary>
        int Length { get; }

        /// <summary>
        /// Dimension (number of y variables)
        /// </summary>
        int Dimension{ get;}

        /// <summary>
        /// Array of x coordinates
        /// </summary>
        double[] x
        {
            get;
        }
        /// <summary>
        /// Array of y vectors. y[i] is the entire history of variable i, i.e. y[i][j] is the value of 
        /// variable i at the x coordinate x[j].
        /// </summary>
        double[][] y
        {
            get;
        }

        /// <summary>
        /// Variable bindings
        /// </summary>
        List<VariableBinding> VariableBindings{ get; set;}
        
        /// <summary>
        /// Output the results
        /// </summary>
        /// <param name="writer"></param>
        void Write(TextWriter writer);

        /// <summary>
        /// Output the results. A log interval dy is specified, and the resultset will be logged with an interval dy 
        /// of the output y[i], where i = indexColumn. 
        /// If logarithmicInterval = true,
        /// dy is a logarithmic interval, i.e. an interval in Log(10,y[i])
        /// </summary>
        /// <param name="writer">Writer to output to</param>
        /// <param name="dy">Log interval</param>
        /// <param name="indexColumn">Index column</param>
        /// <param name="logarithmicInterval">True if the log interval is logarithmic (base 10)</param>
        void Write(TextWriter writer, double dy, int indexColumn, bool logarithmicInterval);
    }

    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="KeyType"></typeparam>
    /// <typeparam name="ValueType"></typeparam>
    public interface IResultAggregate<KeyType, ValueType>
    {
        void Add(KeyType key, ValueType value);

        IList<KeyType> Keys{ get;}

        IList<ValueType> Values{ get;}

    }
}
